<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p>
        上一个p
    </p>
    <div id="outer">
        <span>
            大span
        </span>
        
        <p class="cc">
            大p
            <span>span..</span>
        </p>

        <div>
            大div
        </div>
    </div>

    <span>span...</span>

    <script>
        let div = document.querySelector("#outer");
        //获取div下的所有的子节点
        //childNodes = 标签 + #text
        // let child = div.childNodes;
        // console.log(child[1].nodeName)

        //children - 标签 = 第一层
        let child = div.children;
        console.log(child);
        console.log(div.childElementCount);

        //p
        let p = document.querySelector(".cc");
        //获取父标签
        console.log(p.parentNode.parentNode.parentNode.parentNode.nodeName);//包含#text
        console.log(p.parentElement.parentElement.parentElement.nodeName);

        //获取下一个仅仅跟着的兄弟节点
        let span = div.nextElementSibling;
        console.log(span.nodeName);

        //获取上一个兄弟
        let pre = div.previousElementSibling;
        console.log(pre.nodeName)
    </script>
</body>
</html>